<template>
	<view class="page flexC-FS-C">
		<view class="modules flexC-FS-C">
			<view class="swiper-scroll-view">
				<view class="order-item flexC-FS-SB" v-for="(item, el) in dataList" :key="el">
					<view class="msg flexR-FS-FS">
						<view class="left">
							<img class="faces" :src="imagesYqgjUrl + 'head.png'" @click="headImageClick(faceUrl)"></img>
						</view>
						<view class="right">
							<view class="width100 flexC-FS-FS">
								<view class="msg-content flexR-FS-C mb10">
									<text class="row3 txt20">{{ item.visitorName }}</text>
								</view>
							</view>
						</view>
					</view>
					<view class="msgitem flexR-FS-C">
						<u--image class="EHSbtn" :src="imagesYqgjUrl + 'time.png'" width="46rpx"
							height="46rpx"></u--image>
						<text class="msg-content-title ">来访时间：</text>
						<text class="row3">{{ item.date_val }}</text>
					</view>
					<view class="msgitem flexR-FS-C">
						<u--image class="EHSbtn" :src="imagesYqgjUrl + 'date.png'" width="46rpx"
							height="46rpx"></u--image>
						<text class="msg-content-title ">结束时间：</text>
						<text class="row3">{{ item.date_ed }}</text>
					</view>
					<view class="msgitem flexR-FS-C">
						<u--image class="EHSbtn" :src="imagesYqgjUrl + 'phone.png'" width="46rpx"
							height="46rpx"></u--image>
						<text class="msg-content-title ">访客手机：</text>
						<text class="row3">{{ item.visitorPhone }}</text>
					</view>
					<view class="msgitem flexR-FS-C">
						<u--image class="EHSbtn" :src="imagesYqgjUrl + 'card.png'" width="46rpx"
							height="46rpx"></u--image>
						<text class="msg-content-title">访客身份证：</text>
						<text class="row3">{{ item.visitorIdCardNo }}</text>
					</view>
				</view>
			</view>
		</view>

		<view class="flexC-FS-C visitorbox">
			<view class="btn flexC-Cen" @click="btnVisitorClick('0')">通过</view>
			<view class="btn btn2 flexC-Cen" @click="btnVisitorClick('1')">驳回</view>
			<view class="btn btn2 flexC-Cen" @click="btnVisitorClick('2')">拒绝</view>
		</view>

		<tabbar />
	</view>
</template>

<script>
	import config from '@/configs/index.js'

	export default {
		data() {
			return {
				imagesYqgjUrl: config.IMAGES_URL_YQGJ + 'visitor/',
				dataList: [{
					visitorName: '张扬',
					date_val: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
					date_ed: '08:00—12:00',
					visitorPhone: '13527765555',
					visitorIdCardNo: '415329198005054724',
				}],
				faceUrl: '',
			};
		},
		onShow() {
			this.startInit();
		},
		onLoad(options) {
			this.detailid = options.data;
		},

		methods: {
			startInit() {
				// this.getVisitList();
			},

			getVisitList() {
				const params = {
					id: this.detailid
				};
				this.dataList = [];
				let that = this;
			},
			headImageClick(url) {
				this.handleShowPic([url])
			},
			// 展示照片
			handleShowPic(list) {
				uni.previewImage({
					current: 0,
					indicator: 'number',
					loop: true,
					urls: list
				});
			},
			btnVisitorClick(status) {
				const params = {
					id: this.detailid
				};
				if (status === '0') {
					//通过
					uni.showToast({
						title: '访问通过',
						icon: 'none',
						duration: 500,
						complete: () => {
							setTimeout(() => {
								uni.switchTab({
									url: '/pages/visitor/index'
								});
							}, 300)
						}
					});
				} else if ((status === '1')) {
					//退回,驳回
					uni.showToast({
						title: '已驳回',
						icon: 'none',
						duration: 500,
						complete: () => {
							setTimeout(() => {
								uni.switchTab({
									url: '/pages/visitor/index'
								});
							}, 300)
						}
					});
				} else {
					//拒绝
					uni.showToast({
						title: '已拒绝',
						icon: 'none',
						duration: 500,
						complete: () => {
							setTimeout(() => {
								uni.switchTab({
									url: '/pages/visitor/index'
								});
							}, 300)
						}
					});
				}
			},
		}
	};
</script>

<style scoped lang="scss">
	.page {
		width: 100%;
		height: 100%;
		background-color: #f5f5f5;

		.modules {
			width: 100%;
			padding: 0 34rpx 0px 34rpx;
			height: calc(100% - 240rpx);
			box-sizing: border-box;
			padding-bottom: 20rpx;
			margin-top: 34rpx;

			.swiper-scroll-view {
				width: 100%;
				height: 100%;

				.order-item {
					width: 100%;
					margin: 0 0 30rpx;
					background-color: #ffffff;
					padding: 40rpx;
					border-radius: 6rpx;
					box-sizing: border-box;

					.msgitem {
						width: 100%;
						height: 68rpx;

						.msg-content-title {
							white-space: nowrap;
							width: 200rpx;
							margin-left: 16rpx;
						}
					}

					.msg {
						width: 100%;
						margin-bottom: 28rpx;

						.left {
							margin-top: 14rpx;

							.faces {
								width: 140rpx;
								height: 140rpx;
								border-radius: 50%;
							}
						}

						.right {
							margin-left: 30rpx;
							margin-top: 40rpx;

							.txt20 {
								font-size: 54rpx;
							}
						}

						.msg-content {
							width: 100%;
							font-size: 28rpx;
							font-weight: 500;
							color: #333333;
						}
					}
				}
			}
		}

		.btn {
			width: 82%;
			height: 100rpx;
			margin: 0 auto;
			border-radius: 8rpx;
			color: #ffffff;
			background-color: rgba(65, 174, 104, 1);
			font-size: 32rpx;
			margin-top: 24rpx;
		}

		.btn2 {
			border: 2rpx solid rgba(65, 174, 104, 1);
			color: rgba(65, 174, 104, 1);
			background-color: #ffffff;
		}

		.visitorbox {
			width: 100%;
			width: 100%;
			position: absolute;
			bottom: 0rpx;
			height: 520rpx;
		}
	}

	.animatedTime {
		animation-duration: 300ms;
	}
</style>